package com.example.birdfriends.controller;

import com.example.birdfriends.pojo.recommend.Recommend;
import com.example.birdfriends.pojo.user.User;
import com.example.birdfriends.service.RecommendService;
import com.example.birdfriends.utils.convert.ConvertService;
import com.example.birdfriends.utils.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RequestMapping("/test")
@RestController
public class TestController {
    @Autowired
    private RecommendService recommendService;
    @Autowired
    private ConvertService convertService;
    @Autowired
    private Result result;

    @PostMapping("/testCode")
    public Map<String, Object> testCode(@RequestBody User user){
        Long curLoginUid = user.getId();
        Recommend recommend = recommendService.findRecommendByCurLoginUid(curLoginUid);
        List<String> recPidList = convertService.string2List(recommend.getPidList());

        System.out.println("用户"+curLoginUid+"推荐的帖子数："+recPidList.size());
        return result.resultMap(false, "xxx", recPidList);
    }
}
